<template>
  <div id="code-promote">
    <div class="promote">
      <div class="tab">
        信贷动力分享二维码
      </div>
      <p>当面扫一扫</p>
      <qrcode-addtag :codeurl="codeurl" :logo="logo"></qrcode-addtag>
    </div>
    <share-float :shareshow="shareshow" :friends="friends" v-on:sharefriends="hideshare"></share-float>
    <div class="share" @click="shareincident">分享给好友</div>
    <flexbox orient="vertical">
      <flexbox-item><div class="flex-demo share-flex">分享说明</div></flexbox-item>
    </flexbox>
    <flexbox>
      <flexbox-item><div class="flex-demo">点击分享按钮</div></flexbox-item>
      <img src="../../static/img/jiantou@2x.png" />
      <flexbox-item><div class="flex-demo">选择分享途径</div></flexbox-item>
      <img src="../../static/img/jiantou@2x.png" />
      <flexbox-item><div class="flex-demo">分享成功</div></flexbox-item>
    </flexbox>
  </div>
</template>
<script>
import ShareFloat from '../comment/ShareFloat'
import QrcodeAddtag from '../comment/QrcodeAddtag'
import { Flexbox, FlexboxItem } from 'vux'
import utils from '../utils'
export default {
  data () {
    return {
      shareshow: false,
      friends: false,
      codeurl: '',
      logo: ''
    }
  },
  components: {
    Flexbox,
    FlexboxItem,
    ShareFloat,
    QrcodeAddtag
  },
  created () {
    window.document.title = '二维码推广'
    this.logo = '../../static/img/uxd_logo.png'
    this.codeurl = this.$store.state.Url + '/creditLogin/index?shareParam=share&userId=' + this.$store.state.userID + '&channel=6'
  },
  methods: {
    shareincident () {
      this.shareshow = true
      this.WXsharecontent()
    },
    hideshare () {
      this.shareshow = false
    },
    WXsharecontent () {
      var sharetitle = this.$store.state.shareTitle
      var shareimg = this.$store.state.shareImg
      var sharedesc = this.$store.state.shareDesc
      var shareUrl = this.$store.state.Url + '/creditLogin/index'
      var shareParams = '?shareParam=share&userId=' + this.$store.state.userID
      this.$store.commit('changeIndexConf', {
        shareTitle: sharetitle,
        shareDesc: sharedesc,
        shareImg: shareimg,
        shareLink: shareUrl + shareParams
      })
      utils.refreshShare(this.$wechat, this.$store)
    }
  }
}
</script>
